home *** CD-ROM | disk | FTP | other *** search
- {$P-} { turn pointer checking off.. }
- program degas;
-
- {
-
- Program to save and restore the ST display to/from degas files.
-
- 12/9/86 MJC
-
- Copyright 1986 By OSS, Inc. All Rights Reserved.
-
- Use this code at your own risk.
- }
-
- CONST
- Mono = 2; { monochrome screen resolution }
-
- TYPE
-
- { The ST screen is 32000 bytes of data, soooo.... }
- Screen = packed array [ 0..31999 ] of BYTE;
-
- Ptr_screen = ^Screen; { pointer to the screen array }
-
- Palette = Packed Array [ 0..15 ] of Integer;
-
- Resolution = Integer;
-
- Degas_scrn = PACKED RECORD
- Res : Resolution;
- Pal : Palette;
- Pic : Screen;
- End;
-
- VAR
-
- S_ptr : Ptr_screen; { a pointer to a packed array of bytes... }
- SavScrn : Screen; { a place to save the current screen }
- File_nam : String; { Temp file name.. }
-
- { **********************************************************************
-
- declare routine to get address of screen
-
- *********************************************************************** }
-
- { physbase returns a pointer to the start of the ST's screen. }
-
- FUNCTION Physbase : Ptr_screen;
- XBIOS( 2 );
-
- FUNCTION Getrez : Resolution;
- XBIOS( 4 );
-
- PROCEDURE Setscreen( Logadr, Physadr : Long_Integer; Res : Resolution );
- XBIOS( 5 );
-
- PROCEDURE Setpalette( VAR Pal : Palette );
- XBIOS( 6 );
-
- FUNCTION Setcolor( N , Color : Integer ) : Integer;
- XBIOS( 7 );
-
-
-
- { ***********************************************************************
-
- save screen to degas file.
-
- *********************************************************************** }
-
-
- PROCEDURE SSave( name : STRING );
-
- VAR
-
- f : File of Degas_scrn; { a file containing a degas screen }
- i : Integer;
-
- BEGIN
-
- rewrite( f, name ) ; { bind f to file name }
-
- S_ptr := Physbase; { grab location of screen... }
-
- f^.Res := Getrez; { get resolution word }
-
- FOR i := 0 TO 15 DO { get color palette }
- f^.Pal[ i ] := Setcolor( i, -1 );
-
- f^.Pic := S_ptr^; { get screen data }
-
- put( f ); { and write it out to file }
-
- { file is automatically closed when we leave this procedure. }
-
- END;
-
- { ***************************************************************************
-
- Restore screen data from degas file.
-
- ************************************************************************* }
-
- PROCEDURE SRestore( name : STRING );
-
- VAR
- i : Integer;
- f : file of Degas_scrn; { a file containing a screenful of bytes.. }
- Rez : Resolution;
- Oldpal : Palette;
-
- BEGIN
-
- Rez := Getrez;
- S_ptr := Physbase; { grab location of screen... }
-
- reset( f, name ); { bind f to file name }
-
- { reset automatically fills file buffer with data from first record }
-
- { decide if resolution can be changed... }
- IF ( ( f^.Res < Mono ) AND ( Rez < Mono ) ) THEN
- Setscreen( -1, -1, f^.Res );
-
- { now check for picture compatability... }
-
- IF ( ( f^.Res = Mono ) AND ( Rez = Mono )
- OR
- ( Rez < Mono ) AND ( f^.Res < Mono ) ) THEN
- Begin
- For i:= 0 TO 15 DO { save palette }
- Oldpal[ i ] := Setcolor( i, -1 );
-
- Setpalette( f^.Pal ); { use degas palette }
-
- SavScrn := S_ptr^; { save current screen }
- S_ptr^ := f^.Pic; { stuff picture into screen }
-
- Readln;
- S_Ptr^ := SavScrn; { restore old screen }
- Setpalette( Oldpal ); { restore old palette }
- Setscreen( -1, -1, Rez ) { restore old resolution }
-
- End;
- { file is automatically closed when we leave this procedure. }
- END;
-
-
- { *********************************************************************
-
- miscellaneous subroutines...
-
- *********************************************************************** }
-
-
- PROCEDURE waitCR;
-
- BEGIN
-
- writeln('Press <RETURN> to continue. ');
- readln;
-
- END;
-
-
- { clear screen procedure }
-
- PROCEDURE cls;
-
- BEGIN
-
- write( chr( 27 ) );
- write( 'E' );
-
- END;
-
-
- { put some stupid stuff on the screen... }
-
- PROCEDURE fill_scrn;
-
- VAR
-
- i : integer;
-
- BEGIN
-
- cls; { clear screen ... }
-
- FOR i := 0 TO 20 DO
- BEGIN
- writeln('This is line # ', i );
- END;
- END;
-
-
-
- { ************************************************************************
-
- Main routine starts here. Just execute routines in sequence...
-
- ************************************************************************ }
-
-
- BEGIN
-
- fill_scrn; { put junk on screen.... }
-
- writeln('saving screen...');
-
- File_nam := 'Test.pi'; { start a file name }
- File_nam := Concat(
- File_nam, Chr( Getrez + Ord( '1' ) ) ); { add extender }
-
- SSave( File_nam ); { write screen data to file... }
-
- waitCR;
-
- cls; { clear screen... }
-
- writeln('restoring screen...');
-
- SRestore( File_nam ); { read screen data from file... }
-
- waitCR;
-
- END.
-
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə